package demo1;

public class Fruit {
    public String name;
    protected String color;

    public Fruit(String name, String color) {
        this.name = name;
        this.color = color;
        System.out.println("父类的构造方法被执行了");
    }

    {
        System.out.println("父类的实例代码块2被执行了");
    }

    {
        System.out.println("父类的实例代码块1被执行了");
    }

    static {
        System.out.println("父类的静态代码块2被执行了");
    }

    static {
        System.out.println("父类的静态代码块1被执行了");
    }

    @Override
    public String toString() {
        return "demo1.Fruit{" +
                "name='" + name + '\'' +
                ", color='" + color + '\'' +
                '}';
    }
}
